package main.java.game.item;

import main.java.game.combatant.Hero;

public abstract class Equipable extends Item {
	
	private Integer defenseValue;
	private Integer attackValue;
	private Integer initValue;
		
	public Equipable(String name, Integer defenseValue, Integer attackValue, Integer initValue){
		super(name);
		this.defenseValue=defenseValue;
		this.attackValue=attackValue;
		this.initValue=initValue;
	}
	
	public Integer getDefValue() {
		return defenseValue;
	}

	public Integer getAttackValue() {
		return attackValue;
	}

	public Integer getInitValue() {
		return initValue;
	}

	public void setDefenseValue(Integer defValue) {
		this.defenseValue = defValue;
	}

	public void setAttackValue(Integer atkValue) {
		this.attackValue = atkValue;
	}

	public void setInitValue(Integer initValue) {
		this.initValue = initValue;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((attackValue == null) ? 0 : attackValue.hashCode());
		result = prime * result
				+ ((defenseValue == null) ? 0 : defenseValue.hashCode());
		result = prime * result
				+ ((initValue == null) ? 0 : initValue.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Equipable other = (Equipable) obj;
		if (attackValue == null) {
			if (other.attackValue != null)
				return false;
		} else if (!attackValue.equals(other.attackValue))
			return false;
		if (defenseValue == null) {
			if (other.defenseValue != null)
				return false;
		} else if (!defenseValue.equals(other.defenseValue))
			return false;
		if (initValue == null) {
			if (other.initValue != null)
				return false;
		} else if (!initValue.equals(other.initValue))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return this.getName();
	}
	
	public abstract void equip(Hero h);

	public abstract void unequip(Hero h);
	
}
